<template>
        <el-container>
            <el-header style="background-color:#dcdcdc;">Header</el-header>
            <el-container>
                <el-aside width="200px" style="background-color:beige;">
                    <div v-for="(item, index) in menusData" :key="index">
                       <router-link :to="item.url"> {{item.name }}</router-link> 
                    </div>
                </el-aside>
                <el-main>
                    <router-view />
                </el-main>
            </el-container>
        </el-container>
</template>

<script>
export default {
    data() {
        return {
            menusData: [],
        }
    },
    mounted() {
        let user = localStorage.getItem('rbac_user')
        if (user == null) {
            this.$router.push('/admin/login')
        }
        let id = JSON.parse(user).id
        this.onLoadMenu(id)
    },
    methods: {
        onLoadMenu(id) {
            let url = this.$baseUrl + '/rbac/user/menu'
            this.$http.get(url, {
                params: {
                    userId: id
                }
            }).then(res => {
                console.log(res)
                this.menusData = res.data.data
            })
        }
    }
}
</script>